<include file="Public/min-header" />
<div class="wrapper">
    <include file="Public/breadcrumb" />
    <section class="content">
        <div class="container-fluid">
            <div class="pull-right">
                <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i> 前台导航</h3>
                </div>
                <div class="panel-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_tongyong" data-toggle="tab">前台导航</a></li>
                    </ul>
                    <form method="post" id="addEditNavForm" onsubmit="return checkName();">

                        <div class="tab-content">
                            <div class="tab-pane active" id="tab_tongyong">
                                <table class="table table-bordered">
                                    <tbody>
                                        <tr>
                                            <td class = "text-right">系统内容:</td>
                                            <td>
                                                <select id="system_nav" name="system_nav" class="form-control" style="width:250px;">
                                                    <option value="">自定义导航</option>
                                                    <foreach name="system_nav" key='k' item="v">
                                                        <option value="{$k}" <if condition="$k eq $navigation[url]"> selected </if> >{$v}</option>
                                                    </foreach>
                                                </select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class = "text-right">导航名称:</td>
                                            <td>
                                                <input type="text" value="{$navigation.name}" name="name" class="form-control" style="width:250px;" />
                                                <span id="err_name" style="color:#F00; display:none;">导航名称不能为空!!</span>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class = "text-right">链接:</td>
                                            <td>
                                                <input type="text" value="{$navigation.url}" name="url" class="form-control" />
                                                <span id="err_url" style="color:#F00; display:none;"></span>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class = "text-right">排序:</td>
                                            <td>
                                                <input type="text" value="{$navigation.sort}" name="sort" class="form-control" style="width:200px;" placeholder="50" />
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="pull-right">
                            <input type="hidden" name="id" value="{$navigation.id}">
                            <button class="btn btn-primary" title="" data-toggle="tooltip" type="submit" data-original-title="保存">保存</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
</div>
<script>
// 判断输入框是否为空
function checkName() {
    var name = $("#addEditNavForm").find("input[name='name']").val();
    if ($.trim(name) == '') {
        $("#err_name").show();
        return false;
    }
    return true;
}
// 更改系统内容
$("#system_nav").change(function() {
    var text = $(this).find("option:selected").text();
    text = text.replace(/-/ig, "");
    var val = $(this).find("option:selected").val();
    $("input[name='name']").val(text);
    $("input[name='url']").val(val);
});
</script>
</body>

</html>
